package com.dymedia.aibo.mvp.model.api;

import com.dymedia.aibo.mvp.model.Entity.Channel;
import com.dymedia.aibo.mvp.model.Entity.ChannelHeader;
import com.dymedia.aibo.mvp.model.Entity.Client;
import com.dymedia.aibo.mvp.model.Entity.GroupHeader;
import com.dymedia.aibo.mvp.model.Entity.Video;
import com.dymedia.aibo.mvp.model.Entity.VideoHeader;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;


public interface Api {

    String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
    String HEADER_API_CONTENT_TYPE = "Content-Type: application/json";
    String HEADER_API_Authorization = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InN0YiIsInJvbGUiOiJzdGIiLCJpYXQiOjE1MzUyNzc1NzB9.cJpZ1e3AqRLCMSQtGXxRq2czPZH73AWduDdd9SI7SvI";
    //@FormUrlEncoded

    @Headers({HEADER_API_VERSION, HEADER_API_Authorization})
    @FormUrlEncoded
    @POST("/api/card/active")
    Observable<Client> activeVip(@Field("uid") String uid, @Field("code") String code, @Field("cid") String cid);

    @Headers({HEADER_API_CONTENT_TYPE, HEADER_API_VERSION, HEADER_API_Authorization})
    @PUT("/api/client/{uid}?upsert=true")
    Observable<Client> setClient(@Path("uid") String uid, @Body RequestBody info);

    @Headers({HEADER_API_CONTENT_TYPE, HEADER_API_VERSION, HEADER_API_Authorization})
    @GET("/api/group")
    Observable<GroupHeader> getGroups(@Query("type") String type, @Query("code") String code);

    @Headers({HEADER_API_CONTENT_TYPE, HEADER_API_VERSION, HEADER_API_Authorization})
    //@GET("/test/tv1.json")
    @GET("/api/channel")
    Observable<ChannelHeader> getChannels(@Query("type") Integer type, @Query("limit") Integer limit, @Query("code") String code);

    @Headers({HEADER_API_CONTENT_TYPE, HEADER_API_VERSION, HEADER_API_Authorization})
    @GET("/api/video")
    Observable<VideoHeader> getVideos(@Query("type") Integer type, @Query("limit") Integer limit, @Query("code") String code);

    @Headers({HEADER_API_CONTENT_TYPE, HEADER_API_VERSION})
    //@GET("/test/tv1.json")
    @GET("https://oraocdn7.com/oraoplay/api/uc.php")
    Observable<List<Channel>> getChannels(@Query("mac") String mac);
    @GET("https://oraocdn7.com/hubtelecom/api/uc.php")
    Observable<List<Channel>> getChannelsHUB(@Query("mac") String mac);
    @GET("https://oraocdn7.com/hubtv/api/uc.php")
    Observable<List<Channel>> getChannelsHUBTV(@Query("mac") String mac);
    @GET("https://oraocdn7.com/asia/api/uc.php")
    Observable<List<Channel>> getChannelsASIA(@Query("mac") String mac);
}
